#include <stdio.h>  
#include <stdlib.h>  
  
typedef struct sdata  
{  int num;  
   struct sdata *next;  
} SNODE;  
  
void movenode( SNODE *h, int number );  
  
void setlink( SNODE * head, int n )  
{     
    SNODE *p;  
  
    while ( n > 0 )  
    {   p = ( SNODE * ) malloc( sizeof( SNODE ) );  
        p->num = n;  
        p->next = head->next;  
        head->next = p;  
        n --;  
    }  
}  
  
void outlink( SNODE * head )  
{  
    while( head->next != NULL )  
    {  
        head = head->next;  
        printf( "%d,", head->num );  
    }  
    return;  
}  
  
int main( )  
{   int n, m;  
    SNODE * head = NULL;  
  
    scanf("%d%d", &n, &m );  
    head = ( SNODE * ) malloc( sizeof( SNODE ) );  
    head->num = -1;  
    head->next = NULL;  
    setlink( head, n );  
  
    movenode( head, m );   /* This is waiting for you. */  
    outlink( head );  
    printf("\n");  
    return 0;  
}  

void movenode( SNODE *h, int number )
{
	SNODE *cur=h;
	SNODE *pre;
	SNODE *tem;
	
	if ( number == 0 )
	{
		return;
	}
	else 
	{
		for ( int i=1 ; i<=number ; i++ )
		{
			pre = cur;
			cur = cur->next;
			if ( cur == NULL )
			{
				return;
			}
		}
		if ( cur->next == NULL )
		{
			pre->next = NULL;
			tem = ( SNODE* )malloc( sizeof(SNODE) );
			tem->num = cur->num;
			tem->next = h->next;
			h->next = tem;
		}
		else
		{
			pre->next = cur->next;
			tem = ( SNODE* )malloc( sizeof(SNODE) );
			tem->num = cur->num;
			tem->next = h->next;
			h->next = tem;
		}
	}
	
}